home *** CD-ROM | disk | FTP | other *** search
/ System Booster / System Booster.iso / SYS / s / projdoc.wrx < prev    next >
Text File  |  1996-09-26  |  3KB  |  149 lines

  1. /*
  2.  * Automatic project help
  3.  *
  4.  * seeks the $Helpfile = myfile tag like locale.wrx does
  5.  * sees if the xrefs are loaded, if not loads them and gets
  6.  * the help for the word under the cursor
  7.  *
  8.  * The file given by $Helpfile must not be the real AmigaGuide
  9.  * file but the corresponding XRefs.
  10.  *
  11.  * The function may be passed a parameter. If the parameter equals
  12.  * RELOAD then the only action is to reload the XRef table, after e.g.
  13.  * a change due to a remake.
  14.  *
  15.  * The file may also be passed directly as the second parameter.
  16.  * This is especially useful to reload XRefs from without WRITE
  17.  *
  18.  * © 1994 by Lars Hanke, MGR-Asgard
  19.  *
  20.  * 01/03/1994 first written
  21.  *
  22.  */
  23.  
  24. ARG action file
  25.  
  26. if action = "RELOAD" then reload = 1
  27.   else reload = 0
  28.  
  29. if (reload = 1) & (file ~= "") then relfil = 1
  30.   else relfil = 0
  31.  
  32. OPTIONS RESULTS
  33.  
  34. if relfil = 0 then
  35. do
  36.    IF ~SHOW('P','WRITE') then
  37.    do
  38.      say "This script is for use with the WRITE editor"
  39.      exit 0
  40.    end
  41.  
  42.    address 'WRITE'
  43.  
  44.    'VERSIONCHECK 3848 "ProjDoc.wrx"'
  45.    IF RC~=0 THEN DO
  46.      exit 10
  47.    END
  48.  
  49. end
  50.  
  51. IF reload = 0 then
  52. do
  53.    'GetVar (_CurrentWord)'
  54.    word = RESULT
  55.    err = RC
  56.    do while ((word = "RESULT") & (err = 0))
  57.      'CursorLeft 0'
  58.      err = RC
  59.      'GetVar (_CurrentWord)'
  60.      word = RESULT
  61.    end
  62.    if err ~= 0 then
  63.    do
  64.      'MessageOK (You must have a word in the active window!)'
  65.      exit 0
  66.    end
  67. end
  68.  
  69. if relfil = 0 then
  70. do
  71.    'GetVar (_FilePath)'
  72.    path = RESULT
  73.  
  74.    call pragma(DIRECTORY,path)
  75. end
  76.  
  77. IF ~SHOW('L','amigaguide.library') THEN
  78.    CALL ADDLIB('amigaguide.library',0,-30)
  79.  
  80. if relfil = 1 then
  81. do
  82.   call LoadXRef(file)
  83.   exit(0)
  84. end
  85.  
  86. if reload = 0 then
  87. do
  88.    function = word||'()'
  89.  
  90.    line = GetXRef(word)
  91.    IF line = 10 THEN
  92.      line = GetXRef(function)
  93. end
  94. else line = 10
  95.  
  96. IF line = 10 THEN DO
  97.   /* Now let's see if we still have to load our XRefs */
  98.   'GetVar (_XPos)'
  99.   x = RESULT
  100.   'GetVar (_YPos)'
  101.   y = RESULT
  102.  
  103.   'SetVar (_FindString) ($Helpfile)'
  104.   'Find 1 1 @EOT @EOT {@SILENT}'
  105.   if RC = 0 then
  106.   do
  107.      'GetVar (_CurrentLine)'
  108.      line = RESULT
  109.      line = substr(line,pos("$Helpfile",line))
  110.      line = delword(line,1,1)
  111.      do i=1 until cnt = 0
  112.         ch = substr(line,i,1)
  113.         if ((ch = ':') | (ch = '=') | (ch = ' ')) then cnt = 1
  114.         else cnt = 0
  115.      end
  116.      line = substr(line,i)
  117.      line = word(line,1)
  118.  
  119.      'MessageOK (Ich lade jetzt nicht!)'
  120.      call LoadXRef(line)
  121.   end
  122.  
  123.   'Goto' x y
  124.  
  125.   if reload = 0 then
  126.   do
  127.      line = GetXRef(word)
  128.      IF line = 10 THEN
  129.         line = GetXRef(function)
  130.   end
  131.  
  132. END
  133.  
  134. if reload = 1 then exit 0
  135.  
  136. if line ~= 10 then
  137. do
  138.   parse var line node file xref offset
  139.   node = compress(node,'"')
  140.   file = compress(file,'"')
  141.   call ShowNode(,file,node,offset,xref)
  142. end
  143. else do
  144.   cmd = "run MultiView "||function
  145.   ADDRESS COMMAND cmd
  146. END
  147.  
  148.  
  149.